package inheritance;

public class Animal {
    public String name;
    public int age;
    private String color;       //private只能在同一个类中被访问
    String gener;               //defult只能在同一个包下被访问
    protected  int b;           //不同包时protected只能在子类中被访问


    //当父类中拥有带参构造时，要在子类的构造方法中将父类先构造出来super
    public Animal(String name , int age) {
        this.name = name;
    }

    public void eat(){
        System.out.println(name + "正在吃饭");
    }
}
    //静态成员变量不能被继承
class Dog extends Animal{

        public Dog(String name,int age) {
            super(name,age);
        }

        public void bark(){
            name = "1";
            int b = 1;
            gener = "male";
            //color = "yellow";     color在此处不能访问，具有private权限
        System.out.println(name + "汪汪叫");
    }
}
class Cat extends Animal{
    public Cat(String name , int age) {
        super(name,age);
    }

    public void mew(){
        System.out.println(name + "喵喵喵");
    }
}